<?php

/**
 * AuthorPanelController is the default controller for this application
 */
class AuthorPanelController extends BrowseControllerBase {
	/**
	 * UsersDataService object
	 *
	 * @var UsersDataService object
	 */
	public $usersDataService = null;
	
	/**
	 * Id of the user
	 *
	 * @var int
	 */
	public $userId = null;
	
	/**
	 * Authentication object
	 * @var Authentication object
	 */
	public $authentication = null;
	
	/**
	 * Constructor of index
	 */
	public function __construct() {
		parent::__construct ();
		
		// Init Authentication class
		$this->authentication = new Authentication ();
		
		// Only administrator can be right
		if ($this->authentication->isMember () == false) {
			
			// Go on to login page
			$url = Zend_Registry::get ( 'config' )->APPLICATION_URL . '/Browse/Login/index';
			CommonUtils::redirect ( $url );
			return - 1;
		}
		
		$this->userId = $this->authentication->getCurrentUserId ();
		
		$this->usersDataService = new UsersDataService ();
		$this->smarty->assign ( 'listCountry', CommonDataService::getCountrylist () );
	
	}
	
	/**
	 * The "index" action is the default action for all controllers -- the
	 * landing page of the site.
	 *
	 * @return void
	 */
	public function indexAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/index.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
	
	public function profileAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/profile.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
	
	public function settingAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/setting.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
	
	public function downloadAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/download.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
	
	public function earningAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/earning.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
	
	public function withdrawAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/withdraw.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
	
	public function supportAction() {
		// Summary default
		$this->smarty->assign ( 'SMARTY_CONTENT_PATH', 'Browse/AuthorPanel/support.tpl' );
		$this->smarty->display ( APPLICATION_PATH . '/Layouts/Browse/MainLayout.tpl' );
	}
}